<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改用户文件夹')"/>
    <script th:src="@{/ruoyi/clipboard.min.js}"></script>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-doc-share">
        <input name="id" th:field="${userDoc.fileId}" id="id" type="hidden">
        <input name="urlInfo" th:value="${hostInfo}" id="urlInfo" type="hidden">

        <div class="form-group">

            <label class="col-sm-3 control-label">共享链接地址：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input type="text" id="docUrl" class="form-control" readonly>
                    <span class="input-group-btn">
                        <button type="button" id="btnCopy" class="btn btn-primary">复制链接</button> </span>

                </div>
            </div>

            <div class="form-group">

                <label class="col-sm-3 control-label"></label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <span style="padding-left:18px;">点击下面创建分享按钮后，再将链接发送给微信/QQ好友。</span>

                    </div>
                </div>
            </div>
        </div>

            <!--        <div class="form-group">-->
            <!--            <label class="col-sm-3 control-label">设置密码：</label>-->
            <!--            <div class="col-sm-8">-->
            <!--                <input name="pwd" id="pwd" class="form-control"  maxlength="50"  type="text" >-->
            <!--            </div>-->
            <!--        </div>-->
            <!--        <div class="form-group">-->
            <!--            <label class="col-sm-3 control-label is-required">链接有效期：</label>-->
            <!--            <div class="col-sm-8">-->
            <!--                <select name="validState" class="form-control"-->
            <!--                        th:with="type=${@dict.getType('user_doc_share')}" required>-->
            <!--                    <option value="">请选择</option>-->
            <!--                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"-->
            <!--                            th:value="${dict.dictValue}" ></option>-->
            <!--                </select>-->
            <!--            </div>-->
            <!--        </div>-->

    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "gy/userDoc";

    $("#form-doc-share").validate({
        focusCleanup: true
    });

    $(function () {
        var url = $("#urlInfo").val() + ctx + "gy/userShareDoc/shareDoc/" + $("#id").val();
        $("#docUrl").val(url);
        $("#btnCopy").on("click", function () {
            var content = $("#docUrl").val();
            clipboard = new Clipboard('#btnCopy', {
                text: function () {
                    return content;
                }
            });

            clipboard.on('success', function (e) {
                //   var result = new Object();
                // result.IsSuccess = true;
                // var data = $(".shareDetail").GetJson();
                // $.Put("/api/UserShareDoc/Save?id=" + window.Id, { "": JSON.stringify(data) }, function (result) {
                //     if (result.IsSuccess) {
                //         //   ShowSuccess(result.Msg);
                //         //   setTimeout(function () { $("#share").hide(); }, 2000);
                //         //    page.Query(1);
                //     } else {
                //         ShowError(result.Msg);
                //     }
                // });

                $.modal.alertSuccess("操作成功，共享链接已复制!")

            });

            clipboard.on('error', function (e) {
                console.log(e);
            });

        });
    });

    function submitHandler() {
        if ($.validate.form()) {
            $("#urlInfo").val($("#docUrl").val())
            $.operate.save(ctx + "gy/userShareDoc/add", $('#form-doc-share').serialize());
        }
    }
</script>
</body>
</html>
